﻿/*
 * @author Lee 
 * Time: 20180403 
 * Abstract: SharePoint API的二次封装
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.Web;

namespace SharePointHelper.DLL.SSOM
{
	public class Search
	{
		/// <summary>
		/// 判断 user agent 是否是 SharePoint Search Crawler
		/// </summary>
		/// <param name="context"></param>
		/// <returns></returns>
		public static bool IsSearchUserAgent(HttpContext context)
		{
			if (context != null && context.Request != null && context.Request.Headers != null 
				&& !string.IsNullOrEmpty(context.Request.Headers["User-Agent"]) &&
				context.Request.Headers["User-Agent"].IndexOf("MS Search") != -1)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
}
